/**
 * 代理配置
 * npm start test 表示代理到 http://test-portal-api.asterism.com/
 * npm start 表示代理到 http://dev-portal-api.asterism.com/
 */
module.exports = function getProxy(k) {
  switch (k) {
    //
    case 'test':
      return {
        '/api': {
          target: 'http://test-portal-api.asterism.com/',
          changeOrigin: true,
          pathRewrite: { '^/api': '/api' },
        },
        '/auth': { target: 'http://test-portal-api.asterism.com/', changeOrigin: true, pathRewrite: { '^/auth': '' } },
      };

    // 开发环境
    case 'staging':
      return {
        '/api/asterism': {
          target: 'http://staging-console-api.asterism.com/',
          changeOrigin: true,
          pathRewrite: { '^/api/asterism': '' },
        },
        '/auth': {
          target: 'http://staging-portal-api.asterism.com/',
          changeOrigin: true,
          pathRewrite: { '^/auth': '' },
        },
        '/api/dataGateway': {
          target: 'http://dev-console.asterism.com/',
          changeOrigin: true,
        },
        '/api/dataGatewayFee': {
          target: 'http://dev-console.asterism.com/',
          changeOrigin: true,
        },
      };
    // 测试环境
    default:
      return {
        '/api/smp': {
          target: 'http://172.16.0.43:8002/',
          changeOrigin: true,
          pathRewrite: { '^/api/smp': '' },
        },
        '/api': {
          target: 'http://10.10.0.18:7006/',
          changeOrigin: true,
          pathRewrite: { '^/api': '/api' },
        },
        '/auth': {
          target: 'http://10.10.0.18:7006/',
          changeOrigin: true,
          pathRewrite: { '^/auth': '' },
        },
        '/api/dataGateway': {
          target: 'http://dev-console.asterism.com/',
          changeOrigin: true,
        },
        '/api/dataGatewayFee': {
          target: 'http://dev-console.asterism.com/',
          changeOrigin: true,
        },
      };
  }
};
